FMemoryBlockPool provides a pool of equal sized preallocated memory blocks. More...
#include <fmemory.h>
Public Member Functions | |
FMemoryBlockPool (uint32 delta, uint32 elementSize) | |
Constructor specifying the properties of the pool. | |
~FMemoryBlockPool () | |
destructor | |
void * | newElement () |
allocate an uninitialized memory block from the pool. | |
void | deleteElement (void *el) |
return a block, that has been allocated with newElement () |
FMemoryBlockPool provides a pool of equal sized preallocated memory blocks.
When a lot of equal sized objects are needed, FMemoryPool can be used for fast allocation and with little memory overhead. A standard application is overloading the new operator of a class that is often allocated and deallocated.
FMemoryPool starts empty and preallocates a given number of memory blocks from the heap. If a block is returned to the pool, it is placed on top of a stack of cached objects that are used for fast handling of later allocations.
Memory is not released to the heap until the destructor.
FMemoryPool is thread safe, as it uses FLock to synchronize modifications to the pool.
FMemoryBlockPool | ( | uint32 | delta, | |
uint32 | elementSize | |||
) |
Constructor specifying the properties of the pool.
[in] | delta | : number of memory blocks that are preallocated when there is no unused block available |
[in] | elementSize | : the size of each memory block. It must be greater than sizeof(void*). |
~FMemoryBlockPool | ( | ) |
destructor
void * newElement | ( | ) |
allocate an uninitialized memory block from the pool.
void deleteElement | ( | void * | el | ) |
return a block, that has been allocated with newElement ()